package com.ly.cloud.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.plugins.Page;
import com.ly.cloud.common.mybatisplus.plugins.PageInfo;
import com.ly.cloud.dto.RoleUserQueryDto;
import com.ly.cloud.dto.UserDeleteDto;
import com.ly.cloud.service.UserManagerService;
import com.ly.cloud.vo.UserRoleVo;
import com.ly.cloud.web.utils.WebResponse;

@RestController
@RequestMapping("/userMana")
public class UserManagerController {

	@Autowired
	private UserManagerService userManagerService;
	
	/** 
	 * MethodName:selectUserList
	 * Description: 根据条件查询用户信息
	 * @date: 2018年1月2日
	 */
	@RequestMapping(value="/selectUserListByCon",method=RequestMethod.POST)
	public WebResponse<PageInfo<UserRoleVo>> selectUserList(@RequestBody RoleUserQueryDto dto){
		Page<UserRoleVo> page = userManagerService.selectUserListByCon(new Page<UserRoleVo>(dto.getPageNum(),dto.getPageSize()),dto);
		return new WebResponse<PageInfo<UserRoleVo>>().success(PageInfo.toPageInfo(page));
	}
	
	/** 
	 * Method Name: deleteUserById
	 * Description:  
	 * 根据用户类型和账号删除用户
	 * @param dto 删除用户封装的条件
	 * @date: 2018年1月2日
	 */
	@RequestMapping(value="/deleteUserById",method=RequestMethod.POST)
	public WebResponse<Boolean> deleteUserById(@RequestBody UserDeleteDto dto){
		boolean success  = userManagerService.deleteUserById(dto);
		return new WebResponse<Boolean>().success(success);
	}
	
	/** 
	 * Method Name: deleteUserList
	 * Description:  
	 * 批量删除用户信息
	 * @param dtoList 删除用户封装的条件对象集合
	 * @date: 2018年1月2日
	 */
	@RequestMapping(value="/deleteUserList",method=RequestMethod.POST)
	public WebResponse<Integer> deleteUserList(@RequestBody List<UserDeleteDto> dtoList){
		Integer count  = userManagerService.deleteUserList(dtoList);
		return new WebResponse<Integer>().success(count);
	}
}
